package com.code.webshopapp;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;


public class ImageDownloader extends AsyncTask<String, Void, Bitmap> {

	@Override
	protected Bitmap doInBackground(String... arg0) {
		InputStream inputStream = null;
		try {
			
			URL url = new URL(arg0[0]);
			inputStream = url.openStream();
			return BitmapFactory.decodeStream(inputStream);
			
			
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			
			
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
		return null;
	}
	
	@Override
	protected void onPostExecute(Bitmap result) {
		super.onPostExecute(result);
	}
	

}